<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>我的假单申请</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/X-admin/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:29px">ဂ</i> <i class="layui-icon" style="line-height:30px">刷新</i></a>
        </div>
        <xblock>
        	<button class="layui-btn" onclick="admin_add('添加奖惩人员','__MODULE__/Punish/add','600','500')"><i class="layui-icon">&#xe608;</i>添加</button>
      	<!-- <form style="float:right;" class="layui-form" action="__MODULE__/Teacher/index" method="get">
		      <div class="layui-input-inline">
		        <div class="layui-input-inline">
		        	<input type="text" name="name"  lay-verify="required" placeholder="按姓名查找" autocomplete="off" class="layui-input">
		        </div>
	        </div>
	        <div class="layui-input-inline" style="width:180px">
    	    	<select name="role_id" width="50px" >
    				  <option value="">按角色查找</option>
          		<foreach name="roles" item="rows" >
    			      <option value="{$rows['id']}" >{$rows['name']}</option>
          		</foreach>
    			  </select>
    	  	</div>
		  	<button class="layui-btn" type="submit" lay-filter="formDemo"><i class="layui-icon" style="font-size: 20px;" >&#xe615;</i>搜索</button>
        	</form> -->
        </xblock>

        <div class="layui-tab">
			<div class="layui-tab-content" style="height: 900px;">
				<div class="layui-tab-item layui-show">
					<table class="layui-table">
					  <colgroup>
					    <col width="15%">
					    <col width="15%">
					    <col width="15%">
					    <col width="15%">
					    <col width="15%">
					    <col>
					  </colgroup>
					  <thead>
					    <tr>
                <!-- <th>id号</th> -->
					      <th>学员姓名</th>
					      <th>所在班级</th>
					      <th>扣分原因</th>
					      <th>执行人</th>
					      <th>扣分数</th>
					      <th>扣分时间</th>
					      <th>操作</th>
					    </tr> 
					  </thead>
					  <tbody>
					  	<foreach name="list" item="row" >
					  		<form action="" method="post">
							    <tr>
                    <!-- <td>{$row['id']}</td> -->
							      <td>{$row['stu_name']}</td>
							      <td>{$row['class']}</td>
							      <td>{$row['cause']}</td>
							      <td>{$row['t_name']}</td>
                    <td>{$row['score']}分</td>
							      <td>{$row['created']}</td>
							      <td class="td-manage">
                        <if condition="$row['status'] eq 1 " >
	                         <a title="撤销" href="javascript:;" onclick="admin_del(this,'{$row['id']}','{$row['stu_id']}')" style="text-decoration:none"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;" >&#xe633;撤销</i></a>
                           <else /><i style="font-size:20px;color: #2F4056;" class="layui-icon">&#xe60f;已撤销</i>
                        </if>
	                  </td>
							    </tr>
						    </form>
					  	</foreach>
					  </tbody>
					</table>
         <div class="total">共{$total}条数据</div>
          <!-- 分页信息 -->
          <div id="pages"></div>
        </div>
			</div>
		</div>
	
        <script src="__PUBLIC__/X-admin/lib/layui/layui.js" charset="utf-8"></script>
        <script src="__PUBLIC__/X-admin/js/x-layui.js" charset="utf-8"></script>

        <script>

             layui.use(['laydate','element','laypage','layer','form'], function(){
                $ = layui.jquery;//jquery
  				// var form = layui.form();
              laydate = layui.laydate;//日期插件
              lement = layui.element();//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层
              form = layui.form();
              

              //以上模块根据需要引入
              //调用分页
              laypage({
                cont: 'pages',
                curr: {$curr},
                groups: 5,
                pages: {$page}, //得到总页数
                skip: true,
                jump: function(obj, first){
                  var url = window.location.href;
                  if (!first) {
                    window.location.href=url+"/p/"+obj.curr+".html";
                  }
                }
              }); 
              
            });

            //监听提交
              form.on('submit(save)', function(data){
                console.log(data);
                //发异步，把数据提交给php
                layer.alert("保存成功", {icon: 6},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                });
                return false;
              });

            //批量删除提交
             function delAll () {
                layer.confirm('确认要删除吗？',function(index){
                    //捉到所有被选中的，发异步进行删除
                    layer.msg('删除成功', {icon: 1});
                });
             }
             /*添加*/
            function admin_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }
            //编辑
            function admin_edit (title,url,id,w,h) {
                x_admin_show(title,url,w,h); 
            }
            /*撤销*/
            function admin_del(obj,id,stuid){
                layer.confirm('确认要撤销吗？',function(index){
                    //发异步删除数据                 //pid是userinfo中的pid值
                    $.post("__MODULE__/Punish/back",{id:id,stuid:stuid},function(data){
                      if(data=="撤销成功"){
                          // alert('数据撤销成功');
                          // return false;
                          reload();
                      }
                    });
                    $(obj).parent().html("已撤销");
                    layer.msg('已撤销!',{icon:1,time:1000});
                });
            }
            </script>
            <script>
              function reload(){
                location.replace(location.href);
              }
            </script>
    </body>
</html>